﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IOLib;
using SheetLib;
using SheetLib.Matan;
using SheetLib.Matan.Blocks;

namespace SHS_SE
{
    public partial class F2BlockProps : Form
    {
        Block mathModel;
        public F2BlockProps(Block block)
        {
            InitializeComponent();
            LangSel();
            this.mathModel = block;
            this.textBox1.Text = block.Parameters["A"].ToString();
            this.textBox2.Text = block.Parameters["B"].ToString();
            this.textBox3.Text = block.Parameters["C"].ToString();
            this.listView1.SelectedIndices.Add(Convert.ToInt32(block.Parameters["BlockType"]));
        }

        private void LangSel()
        {
            this.Text = GlobalParams.LanguageForm[243];
            this.label1.Text = GlobalParams.LanguageForm[228];
            this.listView1.Items[0].Text = GlobalParams.LanguageForm[244];
            this.listView1.Items[1].Text = GlobalParams.LanguageForm[245];
            this.button1.Text = GlobalParams.LanguageForm[157];
            this.button2.Text = GlobalParams.LanguageForm[158];
        }

        public object[] GetParamsObjects()
        {
            return new object[] { this.textBox1.Text, this.textBox2.Text, this.textBox3.Text,
                listView1.SelectedIndices[0] };
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                this.mathModel.Parameters["A"] = Convert.ToSingle(this.textBox1.Text);
                this.mathModel.Parameters["B"] = Convert.ToSingle(this.textBox2.Text);
                this.mathModel.Parameters["C"] = Convert.ToSingle(this.textBox3.Text);
                this.mathModel.Parameters["BlockType"] = (F2Block.BlockType)listView1.SelectedIndices[0];
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch
            {
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
